package com.jr.mapper;

import com.jr.pojo.ProviderService;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;
public interface ProviderServiceMapper {

    @Select("SELECT * FROM provider_services WHERE provider_id = #{providerId}")
    List<ProviderService> selectByProviderId(Integer providerId);

    @Select("SELECT * FROM provider_services WHERE service_type_id = #{serviceTypeId}")
    List<ProviderService> selectByServiceTypeId(Integer serviceTypeId);

    @Select("SELECT * FROM provider_services WHERE is_available = 1")
    List<ProviderService> selectAllAvailable();

    @Select("SELECT ps.*, cp.business_name, st.name as service_name, st.base_price, st.price_unit " +
            "FROM provider_services ps " +
            "JOIN care_providers cp ON ps.provider_id = cp.provider_id " +
            "JOIN service_types st ON ps.service_type_id = st.service_type_id " +
            "WHERE ps.is_available = 1 AND cp.status = 'approved'")
    List<ProviderService> selectAllWithDetails();

    @Select("SELECT ps.*, cp.business_name, st.name as service_name, st.base_price, st.price_unit " +
            "FROM provider_services ps " +
            "JOIN care_providers cp ON ps.provider_id = cp.provider_id " +
            "JOIN service_types st ON ps.service_type_id = st.service_type_id " +
            "WHERE ps.provider_id = #{providerId} AND ps.is_available = 1")
    List<ProviderService> selectByProviderIdWithDetails(Integer providerId);
}
